define(['knockout', 'director', 'ko-map', 'ko-amd'], function(ko) {
	var router = Router({});
	router.init();
	var initialModel = {
		appTitle: ko.observable('燕子坞'),
		topMenu: ko.observableArray(),
		yzwModuleOpts: ko.observable(),
		loaded: ko.observable(false),
		init: function() {
			var that = this;
			$.getJSON('/shop/json/example.json', function(returnData) {
				$.each(returnData.topMenu, function(index, data) {
					that.topMenu.push(data);
				});
			});

			setTimeout(function() {
				$("#loading").fadeOut(600);
			}, 1500);
			var that = this;
			//default 
			that.yzwModuleOpts({
				name: 'modules/public/dish/newArrivals',
				template: 'templates/public/dish/newArrivals'
			});

			router.on('/products', function() {
				that.yzwModuleOpts({
					name: 'modules/business/products/list',
					template: 'templates/business/products/list'
				})
			});
			router.on('/dishes', function() {
				that.yzwModuleOpts({
					name: 'modules/public/dish/list',
					template: 'templates//public/dish/list',
					afterRender: function() {
						console.log('telent-test')
					}
				});
			});
			router.on('/myOrder', function() {
				//增加登录判断，如果当前无缓存登录信息或信息已过期，则跳转至登录页面
				if(true) {
					that.yzwModuleOpts({
						name: 'modules/public/account/login',
						template: 'templates/public/account/login'
					})
				} else {
					that.yzwModuleOpts({
						name: 'modules/consumer/order/list',
						template: 'templates/consumer/order/list'
					});
				}

			});
			router.on('/shops', function() {
				that.yzwModuleOpts({
					name: 'modules/business/shop/list',
					template: 'templates/business/shop/list'
				});
			});
			router.on('/shopDetail/:shopId', function(shopId) {
				that.yzwModuleOpts({
					name: 'modules/business/shop/shopDetails',
					template: 'templates/business/shop/shop',
					data: {
						id: shopId
					}
				});
			});
			router.on('/account', function() {
				that.yzwModuleOpts({
					name: 'modules/public/account/login',
					template: 'templates/public/account/login'
				})
			});
			router.on('/cart', function() {
				that.yzwModuleOpts({
					name: 'modules/consumer/order/cart',
					template: 'templates/consumer/order/cart'
				})
			});
			router.on('/register', function() {
				that.yzwModuleOpts({
					name: 'modules/public/account/register',
					template: 'templates/public/account/register'
				});
			})
		}
	}
	return initialModel;
})